
##CC = arm-linux-gnueabihf-gcc
CC = gcc

STRIP = strip 

CFLAGS = -g -O2 


# hal
HAL_SRC_DIR := ../hal
HAL_FILES_C := $(shell find $(HAL_SRC_DIR) -name "*.c")
HAL_HDRDIR := $(shell find $(HAL_SRC_DIR) -type d)
HAL_HDRDIR := $(addprefix -I,$(HAL_HDRDIR))


# src
TC_SRC_DIR := ../src
TC_FILES_C := $(shell find $(TC_SRC_DIR) -name "*.c")
TC_HDRDIR := $(shell find $(TC_SRC_DIR) -type d)
TC_HDRDIR := $(addprefix -I,$(TC_HDRDIR))


#------------------------  all include start ---------------------# 
INC = $(HAL_HDRDIR) $(TC_HDRDIR)
#------------------------ all include end  -----------------------# 


#------------------------ all libs start -------------------------# 
LIBS = -lpthread -lrt -lm 
#------------------------ all libs end  --------------------------# 


#------------------------ all source start -----------------------# 
SRC = test.c $(HAL_FILES_C) $(TC_FILES_C) 

#------------------------ all source end  ------------------------# 

#target
TARGET = test

#objs
OBJS = $(SRC:.c=.o)

$(TARGET):$(OBJS)
	$(CC) -o $@ $^ $(LIBS)

.PHONY: clean

clean:
	rm -f $(OBJS)

install: $(TARGET) clean

%.o:%.c
	$(CC) $(CFLAGS) $(INC) $(LIBS) -o $@ -c $<
